package logic

import (
	"activity/activityRpc/activityRpc"
	"activity/activityRpc/internal/svc"
	"activity/models/mysql"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
)

type ReplyAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReplyAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReplyAddLogic {
	return &ReplyAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ReplyAddLogic) ReplyAdd(in *activityRpc.ReplyAddRequest) (*activityRpc.ReplyAddResponse, error) {
	// todo: add your logic here and delete this line

	reply := mysql.Reply{
		UserId:     int(in.UserId),
		ActivityId: int(in.ActivityId),
		Content:    in.ConTent,
	}

	mysql.DB.Create(&reply)

	return &activityRpc.ReplyAddResponse{
		Id: int64(reply.ID),
	}, nil
}
